package cn.zcib.film.mapper;

import cn.zcib.film.bean.Admin;
import cn.zcib.film.bean.Role;
import cn.zcib.film.bean.vo.AdminVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;


@Mapper
public interface AdminMapper {

    Admin getAdminByaId(Integer aId);

    Admin getAdminByName(@Param("aName") String aName);

    List<Admin> getAdmins(AdminVO vo);

    /**
     * 统计该角色下用户数量
     * @param rId 角色id
     * @return
     */
    @Select("select count(*) from sys_admin_role t1 inner join tbl_admin t2 on t1.a_id = t2.a_id where t1.r_id = #{rId}")
    int getAdminCountByRoleId(Integer rId);

    int saveAdminRole(@Param("aId") Integer aId,@Param("rId") Integer rId);

    int updateAdmin(@Param("aId")Integer aId,@Param("aPassword")Integer aPassword);
    @Select("select * from tbl_admin where a_id = #{aId} and a_password = #{aPassword}")
    Admin getAdminByIdAndPwd(@Param("aId")Integer aId,@Param("aPassword")Integer aPassword);
}
